package com.dayu.web.controller.share;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.dayu.common.annotation.Log;
import com.dayu.common.core.controller.BaseController;
import com.dayu.common.core.domain.AjaxResult;
import com.dayu.common.enums.BusinessType;
import com.dayu.share.domain.ShareGoodsSeries;
import com.dayu.share.service.IShareGoodsSeriesService;
import com.dayu.common.utils.poi.ExcelUtil;
import com.dayu.common.core.page.TableDataInfo;

/**
 * 品牌系列Controller
 * 
 * @author HK
 * @date 2021-04-08
 */
@RestController
@RequestMapping("/share/series")
public class ShareGoodsSeriesController extends BaseController
{
    @Autowired
    private IShareGoodsSeriesService shareGoodsSeriesService;

    /**
     * 查询品牌系列列表
     */
    @PreAuthorize("@ss.hasPermi('share:series:list')")
    @GetMapping("/list")
    public TableDataInfo list(ShareGoodsSeries shareGoodsSeries)
    {
        startPage();
        List<ShareGoodsSeries> list = shareGoodsSeriesService.selectShareGoodsSeriesList(shareGoodsSeries);
        return getDataTable(list);
    }

    /**
     * 导出品牌系列列表
     */
    @PreAuthorize("@ss.hasPermi('share:series:export')")
    @Log(title = "品牌系列", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ShareGoodsSeries shareGoodsSeries)
    {
        List<ShareGoodsSeries> list = shareGoodsSeriesService.selectShareGoodsSeriesList(shareGoodsSeries);
        ExcelUtil<ShareGoodsSeries> util = new ExcelUtil<ShareGoodsSeries>(ShareGoodsSeries.class);
        return util.exportExcel(list, "series");
    }

    /**
     * 获取品牌系列详细信息
     */
    @PreAuthorize("@ss.hasPermi('share:series:query')")
    @GetMapping(value = "/{seriesId}")
    public AjaxResult getInfo(@PathVariable("seriesId") Long seriesId)
    {
        return AjaxResult.success(shareGoodsSeriesService.selectShareGoodsSeriesById(seriesId));
    }

    /**
     * 新增品牌系列
     */
    @PreAuthorize("@ss.hasPermi('share:series:add')")
    @Log(title = "品牌系列", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ShareGoodsSeries shareGoodsSeries)
    {
        return toAjax(shareGoodsSeriesService.insertShareGoodsSeries(shareGoodsSeries));
    }

    /**
     * 修改品牌系列
     */
    @PreAuthorize("@ss.hasPermi('share:series:edit')")
    @Log(title = "品牌系列", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ShareGoodsSeries shareGoodsSeries)
    {
        return toAjax(shareGoodsSeriesService.updateShareGoodsSeries(shareGoodsSeries));
    }

    /**
     * 删除品牌系列
     */
    @PreAuthorize("@ss.hasPermi('share:series:remove')")
    @Log(title = "品牌系列", businessType = BusinessType.DELETE)
	@DeleteMapping("/{seriesIds}")
    public AjaxResult remove(@PathVariable Long[] seriesIds)
    {
        return toAjax(shareGoodsSeriesService.deleteShareGoodsSeriesByIds(seriesIds));
    }
}
